Page({
  data: {
    userNickname: '小明',
    pages: [],
    currentPage: 0,
    playingIndex: -1,
    autoMode: false
  },
  onLoad(options) {
    this.loadDetail(options.recordId);
  },
  loadDetail(recordId) {
    // TODO: 替换为API
    this.setData({
      pages: [
        { imageUrl: '/images/book.png', audioUrl: '', score: 80 },
        { imageUrl: '/images/book-cn.png', audioUrl: '', score: 90 }
      ]
    });
  },
  onPageChange(e) {
    this.setData({ currentPage: e.detail.current });
    if (this.data.autoMode) this.autoPlay();
  },
  onPlay(e) {
    const index = e.currentTarget.dataset.index;
    // TODO: 播放/暂停音频
    this.setData({ playingIndex: this.data.playingIndex === index ? -1 : index });
  },
  onToggleMode() {
    this.setData({ autoMode: !this.data.autoMode });
    if (this.data.autoMode) this.autoPlay();
  },
  autoPlay() {
    // TODO: 自动播放当前页音频并自动翻页
  },
  onBack() {
    wx.navigateBack();
  }
}); 